package com.jiuyue.movehouse.entity;

import com.baomidou.mybatisplus.annotation.*;

import java.util.Date;

import java.io.Serializable;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.NotEmpty;

/**
 * <p>
 * 
 * </p>
 *
 * @author yourFather
 * @since 2022-02-11
 */
@Data
@EqualsAndHashCode(callSuper = false)
public class User implements Serializable {

    private static final long serialVersionUID = 1L;

      @TableId(value = "id", type = IdType.AUTO)
    private Long id;

    /**
     * 用户名
     */
    @NotEmpty(message = "用户名不能为空",groups = {Login.class,Register.class})
    @Length(min = 2,max = 20,message = "用户名需在2~20位",groups = {Register.class})
    private String username;

    /**
     * 密码
     */
    @NotEmpty(message = "密码不能为空",groups = {Login.class,Register.class})
    @Length(min = 6,max = 20,message = "密码需在6~20位",groups = {Register.class})
    private String password;

    /**
     * 昵称
     */
  /*  @NotEmpty(message = "昵称不能为空",groups = {Register.class})
    @Length(max = 20,message = "昵称不能超过20位",groups = {Register.class})
    private String nickname;*/

    /**
     * 管理员 1:是 0:否
     */
    private Integer type;

    /**
     * 逻辑删除
     */
    @TableLogic
    private Long deleted;

    /**
     * 更新时间
     */
    @TableField(updateStrategy = FieldStrategy.NEVER)
    private Date updateTime;

    /**
     * 创建时间
     */
    @TableField(updateStrategy = FieldStrategy.NEVER)
    private Date createTime;

    private Integer haveOrder;

    @NotEmpty(message = "姓名不能为空",groups = {Register.class})
    @Length(min = 2,message = "姓名至少2位",groups = {Register.class})
    private String name;

    @NotEmpty(message = "身份证不能为空",groups = {Register.class})
    private String idCard;

    @NotEmpty(message = "手机号不能为空",groups = {Register.class})
    private String phone;


    public @interface Login{}
    public @interface Register{}
}
